<template>
	<view class="adPages">
		<view class="title">{{ item.title }}</view>
		<!-- <view class="con">群满无法添加</view> -->
		<view class="imgDom" @click="navigateToWeb">
			<template v-if="item.imageUrl">
				<image :src="item.imageUrl" mode="aspectFill"></image>
			</template>
			<template v-else>
				<image src="/post/static/5.png" mode="aspectFill"></image>
			</template>
		</view>
	</view>
</template>

<script setup>
import { getAdInfo } from '@/config/api.js';
import { ref } from 'vue';
import { onShow, onLoad } from '@dcloudio/uni-app';
const schoolInfo = ref({});
onLoad((options) => {
	// console.log(options);
	id.value = options.id;
	const schoolStr = uni.getStorageSync('schoolInfo');
	if (!schoolStr) {
		uni.navigateTo({
			url: '/pages/selectSchool/index?isIndex=1'
		});
	} else {
		const school = JSON.parse(schoolStr);
		schoolInfo.value = school;
		uni.setNavigationBarTitle({
			title: school.schoolName + '校话'
		});
	}
	getAdInfoFun();
});
const id = ref(0);
const item = ref({});
const getAdInfoFun = async () => {
	const res = await getAdInfo(id.value);
	console.log(res.data.item);
	if (res.code == 0) {
		item.value = res.data.item;
	}
};
const navigateToWeb = () => {
	console.log(item.value);
	// 判断平台，小程序需确保域名已配置
	//#ifdef MP-WEIXIN
	uni.showToast({
		title: '请在浏览器中打开',
		icon: 'none'
	});
	// 或者跳转到 web-view（需域名已配置）
	uni.navigateTo({
		url: '/pages/webview/webview?url=' + encodeURIComponent('https://www.baidu.com')
	});
	//#endif

	// App 端直接打开
	//#ifdef APP-PLUS
	plus.runtime.openURL('https://www.baidu.com');
	//#endif

	// H5 端
	//#ifdef H5
	window.open('https://www.baidu.com', '_blank');
	//#endif
};
</script>

<style scoped lang="scss">
.adPages {
	padding: 50rpx;
	.title {
		width: 100%;
		text-align: center;
		font-weight: 700;
	}
	.con {
		padding-top: 25rpx;
		width: 100%;
		font-size: 28rpx;
		text-align: center;
		font-weight: 700;
	}
	.imgDom {
		justify-content: center;
		align-items: center;
		margin-top: 25rpx;
		width: 100%;
		height: 800rpx;
		border-radius: 20rpx;
		background-color: #fff;
		overflow: hidden;
	}
}
</style>
<style>
page {
	background: #f8f8fa;
}
image {
	width: 100%;
	height: 100%;
}
.mT20 {
	margin-top: 20rpx;
}
.red {
	color: #e53939;
}
.bor {
	background: linear-gradient(44deg, #5384f7 0%, #5744e8 100%);
	border: 2rpx solid;
	border-image: linear-gradient(44deg, rgba(83, 132, 247, 1), rgba(87, 68, 232, 1)) 2 2;
}
.modalBut {
	align-items: center;
	justify-content: space-around;
	width: 100%;
}
.custom_btn {
	width: 40%;
	height: 70rpx;
	line-height: 70rpx;
	border-radius: 35rpx;
	text-align: center;
	color: #fff;
	background-color: #3391e6;
}
.nodeBut {
	color: #515151;
	background-color: #f0f0f0;
}

.card {
	margin-bottom: 20rpx;
	background-color: #fff;
	border-radius: 15rpx;
}
.noData {
	width: 100%;
	color: #999;
	text-align: center;
}
</style>
